home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 2 / Apprentice-Release2.iso / Source Code / Peter Lewis / Finger 1.3.5 / source / My Units / MyTrackIdle.unit < prev    next >
Encoding:
Text File  |  1992-02-24  |  1.5 KB  |  68 lines  |  [TEXT/PJMM]

  1. unit MyTrackIdle;
  2.  
  3. { This code is part of the Finger/Fingerd source code, written in THINK Pascal 4 }
  4. { Copyright 1991-1992 Peter N Lewis }
  5. { If you use this code, you must give me credit in your about box and documentation }
  6. { This is part of my generic library of routines }
  7.  
  8. interface
  9.  
  10.     function IdleSince: longInt;  {TickCount at last no idle time}
  11.     procedure InitTrackIdle;
  12.     procedure FinishTrackIdle;
  13.     procedure TrackIdle;
  14.  
  15. implementation
  16.  
  17.     type
  18.         keyLongMap = array[1..4] of longInt;
  19.  
  20.     var
  21.         lastmoved: longInt;  { Last time the cursor was moved, used for idle timing }
  22.         lastpos: point;
  23.         lastkeymap: keyLongMap;
  24.  
  25.     function IdleSince: longInt;  {TickCount at last no idle time}
  26.     begin
  27.         IdleSince := lastmoved;
  28.     end;
  29.  
  30.     procedure MyGetMouse (var pt: point); { Handles not having quickdraw around }
  31.         var
  32.             mousep: ^point;
  33.     begin
  34.         mousep := POINTER($830);
  35.         pt := mousep^;
  36.     end;
  37.  
  38.     procedure TrackIdle;
  39.         var
  40.             pt: point;
  41.             km: keyLongMap;
  42.     begin
  43.         pt := lastpos;
  44.         MyGetMouse(lastpos);
  45.         if (abs(pt.h - lastpos.h) > 2) or (abs(pt.v - lastpos.v) > 2) then begin
  46.             lastmoved := TickCount;
  47.         end
  48.         else begin
  49.             GetKeys(keyMap(km));
  50.             if (km[1] <> lastkeymap[1]) or (km[2] <> lastkeymap[2]) or (km[3] <> lastkeymap[3]) or (km[4] <> lastkeymap[4]) then begin
  51.                 lastmoved := TickCount;
  52.                 lastkeymap := km;
  53.             end;
  54.         end;
  55.     end;
  56.  
  57.     procedure InitTrackIdle;
  58.     begin
  59.         MyGetMouse(lastpos);
  60.         lastmoved := TickCount;
  61.         GetKeys(keyMap(lastkeymap));
  62.     end;
  63.  
  64.     procedure FinishTrackIdle;
  65.     begin
  66.     end;
  67.  
  68. end.